package oop4.supermarket;

import java.util.Scanner;

public class TestSupermarket {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Supermarket a = new Supermarket();
        a.name = "世纪华联";
        a.address = "南京东路170号";
        int choice = 0;
        while (true) {
            System.out.println("1:加新会员，2:查看超市和会员信息，3:给指定用户涨分，4:兑换礼品，5:获得获得超市会员人数，6:返回积分值最大的会员，9:退出");
            System.out.print("请选择:");
            choice = input.nextInt();
            if (choice == 1) {
                System.out.println("--加新会员--");
                Member b = new Member();
                System.out.print("请输入新会员姓名:");
                b.setName(input.next());
                System.out.print("请输入新会员号:");
                b.setCardNo(input.next());
                System.out.print("请输入新会员的积分:");
                b.setJifen(input.nextInt());
                System.out.print("请输入新会员手机号:");
                b.setPhone(input.next());
                if (a.add(b)) {
                    System.out.println("新会员添加成功");
                } else {
                    System.out.println("新会员添加失败");
                }
            } else if (choice == 2) {
                System.out.println("--查看超市信息--");
                a.show();
            } else if (choice == 3) {
                System.out.println("--给指定用户涨分--");
                System.out.print("请输入会员号:");
                String cardNo = input.next();
                System.out.print("请输入要涨多少积分:");
                int addjifen = input.nextInt();
                boolean c = a.inc(cardNo, addjifen);
                if (c) {
                    System.out.println("涨分成功");
                } else {
                    System.out.println("账号不存在");
                }
            } else if (choice == 4) {
                System.out.println("--兑换礼品--");
                System.out.print("请输入会员号:");
                String cardNo = input.next();
                System.out.print("请输入要兑换的礼品类型序号:");
                int i = input.nextInt();
                System.out.println("兑换的结果是" + a.duiHuan(cardNo, i));
            } else if (choice == 5) {
                System.out.println("--获得超市会员人数--");
                System.out.println("超市会员人数为" + a.getRenShu());
            } else if (choice == 6) {
                System.out.println("--返回积分值最大的会员--");
                Member b = a.getBiggestJifen();
                if (b == null) {
                    System.out.println("会员数组为空，没有最大积分的会员");
                } else {
                    System.out.println("积分值最大的会员是" + b.getName());
                }
            } else if (choice == 9) {
                System.out.println("退出");
                break;
            }
        }

    }
}
